Debug stream text msg improvements#10845
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves debug stream text messaging for Zephyr-based SOF builds by making ds_send_text_record() callable from user space via a syscall and by exporting ds_msg() for use from module code.
Changes:
- Register
debug_stream_text_msg.hfor Zephyr syscall header generation. - Add
ds_send_text_record()API as a Zephyr syscall (whenCONFIG_USERSPACEis enabled) and introduceDS_TEXT_MSG_MAX_LEN. - Implement syscall plumbing (
z_impl_*/z_vrfy_*+ marshalling include) and exportds_msg().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
zephyr/CMakeLists.txt |
Adds the header to Zephyr’s syscall generation inputs. |
src/include/user/debug_stream_text_msg.h |
Introduces DS_TEXT_MSG_MAX_LEN and the ds_send_text_record() syscall/public prototype. |
src/debug/debug_stream/debug_stream_text_msg.c |
Implements the syscall handler + verifier and exports ds_msg(); refactors text record sending path. |
| void ds_vamsg(const char *format, va_list args) | ||
| { | ||
| char text[DS_TEXT_MSG_MAX_LEN]; | ||
| ssize_t len; | ||
|
|
||
| len = vsnprintf(text, sizeof(text), format, args); | ||
|
|
||
| if (len < 0) | ||
| return; | ||
| len = MIN(len, sizeof(text)); | ||
|
|
||
| ds_send_text_record(text, len); | ||
| } |
There was a problem hiding this comment.
Hmmm, I'll make debug_stream_slot_send_record() a syscall instead.
| void z_impl_ds_send_text_record(const char *text, size_t len) | ||
| #else | ||
| void ds_send_text_record(const char *text, size_t len) | ||
| #endif |
There was a problem hiding this comment.
usually we don't have to do this - we just define z_impl_...() functions and the Zephyr syscall magic calls those when userspace is disabled. Why is this needed here?
| len = vsnprintf(buf.text, sizeof(buf.text), format, args); | ||
|
|
||
| if (len < 0) | ||
| if (!text || len == 0) |
There was a problem hiding this comment.
this is a curious mix of == 0 and !x styles ;-) I won't say which one I prefer, but can we have just one of them at least within a single if? :-)
There was a problem hiding this comment.
Ok. I drop len check. The code can cope with zero length.
Export ds_msg() to allow using it in loadable modules. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Make debug_stream_slot_send_record() a Zephyr syscall when CONFIG_USERSPACE is enabled. This allows user-space threads to send debug stream records directly. Rename the implementation to z_impl_debug_stream_slot_send_record() and add z_vrfy_debug_stream_slot_send_record() with K_SYSCALL_MEMORY_READ validation of the record buffer. Register the syscall header in CMakeLists.txt. Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
776028e to
d9364e5
Compare
Make ds_send_text_record() a syscall to make userspace debugging easier. And export ds_msg() to allow its usage in module code.